package com.study.springboot.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试配置文件的加载顺序 由低到高 共享配置-->扩展配置-->当前服务配置
 */
@RestController
@RequestMapping("api/v1/config")
@RefreshScope// 配置更新后生效 配置动态更新
public class TestInitConfigOrderController {
    @Value("${test}")
    private String value;
    @Value("${ext:''}")
    private String ext;

    @Value("${share:''}")
    private String share;

    @GetMapping("/test")
    public ResponseEntity<String> test() {
        return ResponseEntity.ok(value);
    }
    @GetMapping("/share")
    public ResponseEntity<String> share() {
        return ResponseEntity.ok(share);
    }

    @GetMapping("/ext")
    public ResponseEntity<String> ext() {
        return ResponseEntity.ok(ext);
    }
}
